package lime.user.view;

import lime.model.User;

import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

public class UserFilter extends ViewerFilter {

	private String contains;
	
	@Override
	public boolean select(Viewer viewer, Object parentElement, Object element) {

		User user = (User) element;
		
		if (StringUtils.isNotBlank(contains)) {
			String regex = ".*" + contains + ".*";
			if (!user.getObjectName().matches(regex)) {
				return false;
			}
		}
		
		return true;
	}
	
	public String getContains() {
		return contains;
	}
	
	public void setContains(String contains) {
		this.contains = contains;
	}
	
}
